package com.yict.csms.system.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.yict.common.dao.impl.CommonDao;
import com.yict.csms.resourceplan.entity.RtgcFlWhartNeed;
import com.yict.csms.resourceplan.entity.RtgcFlWhartNeedHour;
import com.yict.csms.system.entity.Wharf;

/**
 * 
 * 
 * @author Patrick.Deng
 * 
 */
@Repository
public class WharfDaoImpl extends CommonDao<Wharf, Long> {

	public RtgcFlWhartNeed findBySegment(String Segment,String timeId){
		String queryString = "from RtgcFlWhartNeed r where r.forsegment='"+Segment+"' and  r.rtgcFlTime.timeid='"+timeId+"'";
		RtgcFlWhartNeed vo = new RtgcFlWhartNeed();
		try {
			if(timeId!=null&&!"".equals(timeId)){
			List<RtgcFlWhartNeed> list = this.getTemplate().find(queryString);
			if(list.size()>0){
				vo=list.get(0);
			}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return vo;
	}

	public RtgcFlWhartNeedHour findByNeedHourSegment(String segment,String timeId){
		String queryString = "from RtgcFlWhartNeedHour r where r.forSegment='"+segment+"' and r.rtgcFlTime.timeid='"+timeId+"'";
		RtgcFlWhartNeedHour vo = new RtgcFlWhartNeedHour();
		try {
			if(segment!=null&&!"".equals(segment)&&timeId!=null&&!"".equals(timeId)){
			List<RtgcFlWhartNeedHour> list = this.getTemplate().find(queryString);
			if(list.size()>0){
				vo=list.get(0);
			}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return vo;
	}
	
	public Wharf findById(Long id) {
		return (Wharf) this.getTemplate().get(Wharf.class, id);
	}
}
